<?php
//当前控制器的命名空间，对应Application/Home/Controller
namespace Admin\Controller;
//引用的命名空间，对应ThinkPHP/Library/THink目录
use Think\Controller;
use Think\Crypt\Driver\Think;

class LoginController extends Controller {
	public function index() {
		if(IS_POST) {
			if(!$this -> checkVerify(I('post.verify'))) {
				$this -> error('验证码错误', U('index'));
			}
			$Admin = D('shop_admin');
			$username = $Admin -> username;
			if ($Admin -> checkLogin()) {
				session('userinfo',array('name' => $username));
				$this -> redirect('index');
			}
			$this -> error('登录失败，账号密码错误',U('index'));
		}

		$this -> display();
	}

	public function getVerify() {
		$Verify = new \Think\Verify();
		$Verify -> entry();
	}

	public function checkVerify($code, $id=''){
		$Verify = new \Think\Verify;
		return $Verify -> check($code, $id);
	}
}